package com.oamic.xiaomi.serverproject.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.time.LocalDateTime;

@Data
@TableName("fault_report")
public class FaultReport {
    
    @TableId(type = IdType.AUTO)
    private Long id;
    
    /**
     * 线路名称
     */
    private String lineName;
    
    /**
     * 故障区段
     */
    private String faultSection;
    
    /**
     * 故障类型：路基沉降、钢轨裂纹
     */
    @TableField(value = "fault_type", typeHandler = com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler.class)
    private FaultType faultType;
    
    /**
     * 报修人
     */
    private String reporter;
    
    /**
     * 报修时间
     */
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime reportTime;
    
    /**
     * 处理状态：待处理、处理中、已解决
     */
    @TableField(value = "status", typeHandler = com.baomidou.mybatisplus.core.handlers.MybatisEnumTypeHandler.class)
    private FaultStatus status;
    
    /**
     * 处理结果
     */
    private String resolution;
    
    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;
    
    /**
     * 更新时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;
    
    /**
     * 逻辑删除标识：0-未删除，1-已删除
     */
    @TableLogic
    private Integer deleted;
    
    public enum FaultType {
        ROADBED_SETTLEMENT("路基沉降"),
        RAIL_CRACK("钢轨裂纹");
        
        @EnumValue
        private final String description;
        
        FaultType(String description) {
            this.description = description;
        }
        
        public String getDescription() {
            return description;
        }
        
        @Override
        public String toString() {
            return name();
        }
    }
    
    public enum FaultStatus {
        PENDING("待处理"),
        PROCESSING("处理中"),
        RESOLVED("已解决");
        
        @EnumValue
        private final String description;
        
        FaultStatus(String description) {
            this.description = description;
        }
        
        public String getDescription() {
            return description;
        }
        
        @Override
        public String toString() {
            return name();
        }
    }
}